#include"Point.h"
#include"Circle.h"

//友元全局函数：其实现是作为一个全局的函数实现
//void printPoint1(const class&) 声明是在类内
void printPoint1(const Point& p) {
	cout << "Point(" << p.x << ", " << p.y << ")"<<endl;
}


int main() {
	cout << "友元全局函数" << endl;//全局实现
	Point* p = new Point(3.14, 6.28);
	printPoint1(*p);
	delete p; p = NULL;
	cout << "==========================" << endl;

	cout << "友元成员函数" << endl;//其他类(Cycle)内实现 void printPoint2(const class&)
	Point* p0 = new Point(6.66, 7.77);
	Circle* c0 = new Circle;
	c0->printPoint2(*p0);
	delete p0; delete c0;
	p0 = NULL; c0 = NULL;
	cout << "==========================" << endl;

	cout << "静态数据成员和静态成员函数" << endl;

	cout << "==========================" << endl;
	Point* p1 = new Point(1.11, 2.22);
	cout << "当前Point数量为：" << p1->getcount() << endl;
	Point* p2 = new Point(3.33, 4.44);
	cout << "当前Point数量为：" << p2->getcount() << endl;
	Point* p3 = new Point(5.55, 6.66);
	cout << "当前Point数量为：" << p3->getcount() << endl;
	cout << "\n" << endl;
	cout << "当前Point数量为：" << Point::getcount() << endl;
	delete p1; p1 = NULL;
	delete p2; p2 = NULL;
	cout << "当前Point数量为：" << p3->getcount() << endl;
	
	cout << "当前Point数量为：" << Point::getcount() << endl;
	delete p3; p3 = NULL;									//即使在类外我们也能调用,获取静态私有数据成员
	cout << "当前Point数量为：" << Point::getcount() << endl;//使其达到一个近似全局变量的效果
	cout << "==========================" << endl;
	

	return 0;
}